<?php
/**
 * Created by PhpStorm.
 * User: 小蛮哼哼哼
 * Email: 243194993@qq.com
 * Date: 2021/10/22
 * Time: 16:05
 * motto: 现在的努力是为了小时候吹过的牛逼！
 */

declare(strict_types=1);

namespace app\common\model\mysql;

use app\common\lib\Status;

class SeatDetail extends Base
{
    /**
     * @param int $seat_id
     * @param string $field
     * @return array
     * @throws \think\db\exception\DataNotFoundException
     * @throws \think\db\exception\DbException
     * @throws \think\db\exception\ModelNotFoundException
     */
    public function getSeatDetailByList(int $seat_id = 0, string $field = '*'): array
    {
        return $this->field($field)
            ->where('seat_id', $seat_id)
            ->select()
            ->toArray();
    }

    /**
     * @param int $seat_id
     * @return array
     * @throws \think\db\exception\DataNotFoundException
     * @throws \think\db\exception\DbException
     * @throws \think\db\exception\ModelNotFoundException
     */
    public function getSeatDetailBySeatId(int $seat_id = 0): array
    {
        return $this->where('seat_id', $seat_id)
            ->select()
            ->toArray();
    }

    /**
     * @param array $ids
     * @param string $field
     * @return array
     * @throws \think\db\exception\DataNotFoundException
     * @throws \think\db\exception\DbException
     * @throws \think\db\exception\ModelNotFoundException
     */
    public function getSeatDetailByIds(array $ids = [], string $field = "*")
    {
        return $this->field($field)
            ->where('id', 'in', $ids)
            ->select()
            ->toArray();
    }

    /**
     * 查询座位
     * @param int $seat_id
     * @param int $seatX
     * @param int $seatY
     * @return SeatDetail|array|\think\Model|null
     * @throws \think\db\exception\DataNotFoundException
     * @throws \think\db\exception\DbException
     * @throws \think\db\exception\ModelNotFoundException
     */
    public function getSeatDetailBySeatIdAndSeat(int $seat_id = 0, int $seatX = 0, int $seatY = 0)
    {
        return $this->field('*')
            ->where('seat_id', $seat_id)
            ->where('seatX', $seatX)
            ->where('seatY', $seatY)
            ->find();
    }

    public function getBaseByIdsValue(array $ids = [], string $field = '*'): array
    {
        return $this->field($field)
            ->where('SeatCode', 'in', $ids)
            ->select()
            ->toArray();
    }
}
